package com.xinli.business.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinli.common.annotation.Log;
import com.xinli.common.core.controller.BaseController;
import com.xinli.common.core.domain.AjaxResult;
import com.xinli.common.enums.BusinessType;
import com.xinli.business.domain.TTsyd;
import com.xinli.business.service.ITTsydService;
import com.xinli.common.utils.poi.ExcelUtil;
import com.xinli.common.core.page.TableDataInfo;

/**
 * 特殊约定Controller
 *
 * @author ruoyi
 * @date 2025-04-12
 */
@RestController
@RequestMapping("/business/tsyd")
public class TTsydController extends BaseController
{
    @Autowired
    private ITTsydService tTsydService;

    /**
     * 查询特殊约定列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TTsyd tTsyd)
    {
        startPage();
        List<TTsyd> list = tTsydService.selectTTsydList(tTsyd);
        return getDataTable(list);
    }

    /**
     * 导出特殊约定列表
     */
    @Log(title = "特殊约定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TTsyd tTsyd)
    {
        List<TTsyd> list = tTsydService.selectTTsydList(tTsyd);
        ExcelUtil<TTsyd> util = new ExcelUtil<TTsyd>(TTsyd.class);
        util.exportExcel(response, list, "特殊约定数据");
    }

    /**
     * 获取特殊约定详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(tTsydService.selectTTsydById(id));
    }

    /**
     * 新增特殊约定
     */
    @Log(title = "特殊约定", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated  @RequestBody TTsyd tTsyd)
    {
        return toAjax(tTsydService.save(tTsyd));
    }

    /**
     * 修改特殊约定
     */
    @Log(title = "特殊约定", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody TTsyd tTsyd)
    {
        return toAjax(tTsydService.updateById(tTsyd));
    }

    /**
     * 删除特殊约定
     */
    @Log(title = "特殊约定", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tTsydService.removeByIds(Arrays.asList(ids)));
    }
}
